from enum import Enum, IntEnum


class SexEnum(int, Enum):
    """
    性别枚举
    """

    unknown = 0
    man = 1  # 男
    woman = 2  # 女

    @classmethod
    def key_list(cls):
        return list(map(lambda c: c.value, cls))


def get_sex(val):
    if not isinstance(val, int):
        return "未知"
    sex_dict = {1: "男", 2: "女"}
    return sex_dict.get(val, "未知")


class LoginTypeEnum(int, Enum):
    """
    用户端登录方式枚举
    """

    account = 1  # 账号登录
    sms = 2  # 手机短信验证码登录
    wechat_office = 3  # 微信公众号登录
    wechat_mnp = 4  # 微信小程序登录


def get_login_type(val):
    type_dict = {
        "account": "账号登录",
        "mnp": "微信登录",
        "mobile": "手机号登录",
        "office": "公众号登录",
    }
    return type_dict.get(val, "未知")


class LoginClientEnum(int, Enum):
    """
    客户端类型枚举
    """

    MNP = 1  # ("微信小程序"),
    OA = 2  # ("微信公众号"),
    H5 = 3  # ("手机H5"),
    PC = 4  # ("电脑PC"),
    IOS = 5  # ("苹果APP"),
    APK = 6  # ("安卓APP");


class WXOauthScopeEnum(str, Enum):
    BASE = "snsapi_base"  # 微信授权登录 基本
    USERINFO = "snsapi_userinfo"  # 微信授权登录 获取用户信息


def get_login_client(val):
    if not isinstance(val, int):
        return "未知"
    _dict = {
        1: "微信小程序",
        2: "微信公众号",
        3: "手机H5",
        4: "电脑PC",
        5: "苹果APP",
        6: "安卓APP",
    }
    return _dict.get(val, "未知")


class PageTypeEnum(int, Enum):
    """
    页面装修-页面类型枚举
    """

    HOME = 1  # 首页
    USER_CENTER = 2  # 个人中心
    CUSTOMER_SERVICE = 3  # 客服设置


class NoticeEnum(IntEnum):
    SMS_LOGIN_CODE = 101
    SMS_BIND_MOBILE_CODE = 102
    SMS_CHANGE_MOBILE_CODE = 103
    SMS_FORGOT_PASSWORD_CODE = 104

    @property
    def msg(self):
        msg_dict = {
            101: "登录验证码",
            102: "绑定手机验证码",
            103: "变更手机验证码",
            104: "找回登录密码验证码",
        }
        return msg_dict.get(self.value, "")


class PolicyTypeEnum(str, Enum):
    """
    政策协议类型枚举
    """

    SERVICE = "service"
    PRIVACY = "privacy"


class SmsEnum(int, Enum):
    LOGIN = (101,)
    BIND_MOBILE = (102,)
    CHANGE_MOBILE = (103,)
    FIND_PASSWORD = 104


class ActivityTypeEnum(int, Enum):
    """
    活动类型枚举
    """

    GUAGUALE = 1  # 刮刮乐
    QRCODE = 2  # 二维码

    @classmethod
    def get_label(cls, val: int) -> str:
        """获取枚举名称"""
        if not isinstance(val, int):
            return "未知"
        status_dict = {
            1: "刮刮乐",
            2: "二维码",
        }
        return status_dict.get(val, "未知")


class ActivityStatusEnum(int, Enum):
    """
    活动状态枚举
    """

    DRAFT = 0  # 草稿
    WAIT = 1  # 待开始
    START = 2  # 进行中
    END = 3  # 结束
    ONLINE = 4  # 上架
    OFFLINE = 5  # 下架
    CANCELED = 6  # 作废/废弃

    @classmethod
    def get_label(cls, val):
        if not isinstance(val, int):
            return "未知"
        status_dict = {
            1: "待开始",
            2: "进行中",
            3: "结束",
            4: "取消",
        }
        return status_dict.get(val, "未知")


class PrizeLevelEnum(str, Enum):
    """
    奖品等级枚举
    """

    THANKS = 0
    FIRST = 1
    SECOND = 2
    THIRD = 3
    FOURTH = 4
    FIFTH = 5
    SIXTH = 6
    SEVENTH = 7
    EIGHTH = 8
    NINTH = 9
    TENTH = 10
    ELEVENTH = 11

    @classmethod
    def get_label(cls, value):
        if not isinstance(value, int):
            return "未知"
        label_dict = {
            0: "谢谢参与",
            1: "一等奖",
            2: "二等奖",
            3: "三等奖",
            4: "四等奖",
            5: "五等奖",
            6: "六等奖",
            7: "七等奖",
            8: "八等奖",
            9: "九等奖",
            10: "十等奖",
            11: "十一等奖",
        }
        return label_dict.get(value, "未知")


class CodeStatusEnum(int, Enum):
    UNUSED = 1  # 未使用
    USED = 2  # 已使用
    BOUND = 3  # 已绑定

    @classmethod
    def get_str(cls, value: int):
        label_dict = {
            1: "未使用",
            2: "已使用",
            3: "已绑定",
        }
        return label_dict.get(value, "未知")


class CodeBatchStatusEnum(IntEnum):
    PUT_INIT = 0  # 未入库
    PUTTING = 1  # 入库中
    PUT_END = 2  # 入库完成

    @classmethod
    def get_str(cls, value: int):
        label_dict = {
            0: "未入库",
            1: "入库中-刷新可查看进度",
            2: "入库完成",
        }
        return label_dict.get(value, "未知")


class ActivitOrderStatusEnum(IntEnum):
    NEW = 1  # 新订单
    PAST = 2  # 订单过期
    CANCLE = 3  # 核销

    @classmethod
    def get_str(cls, value: int):
        label_dict = {
            1: "新订单",
            2: "已过期",
            3: "已兑奖",
        }
        return label_dict.get(value, "未知")
